package com.poetize.plus.entity.vo;

import com.poetize.plus.entity.po.User;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * @author zuosy
 * @created 2024/4/3 11:10
 */
public record UserVO(
        @Schema(description = "ID")
        Long id,

        @Schema(description = "头像")
        String avatar,

        @Schema(description = "用户名")
        String username,

        @Schema(description = "角色")
        String role,

        @Schema(description = "邮箱")
        String email,

        @Schema(description = "性别")
        String gender,
        @Schema(description = "简介")
        String introduction
) {

    /**
     * 实体类转VO
     *
     * @param user
     * @return
     */
    public static UserVO convert(User user) {
        return new UserVO(user.getId(), user.getAvatar(), user.getUsername(), user.getRole(), user.getEmail(), user.getGender(), user.getIntroduction());
    }
}
